package com.nxmu.hire.controller;

import com.nxmu.hire.common.util.ResponseResult;
import com.nxmu.hire.model.EnumMap.EnumMap;
import com.nxmu.hire.model.Research;
import com.nxmu.hire.model.enums.CollegeEnum;
import com.nxmu.hire.model.param.ParameterFactory;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin(origins = "*",allowCredentials = "true")
@RestController
@RequestMapping("/enum")
public class EnumFetchController {

    @Autowired
    private ParameterFactory parameterFactory;

    @ApiOperation(value = "获取学院枚举")
    @GetMapping("/college")
    public ResponseResult getCollegeEnumMap(){
        return ResponseResult.success(EnumMap.collegeEnumMap);
    }

    @ApiOperation(value = "获取学历枚举")
    @GetMapping("/education")
    public ResponseResult getEducationEnumMap(){
        return ResponseResult.success(EnumMap.educationEnumMap);
    }

    @ApiOperation(value = "获取角色枚举")
     @GetMapping("/role")
    public ResponseResult getRoleEnumMap(){
        return ResponseResult.success(EnumMap.roleEnumMap);
    }

    @ApiOperation(value = "获取职称枚举")
    @GetMapping("/title")
    public ResponseResult getTitleEnumMap(){
        return ResponseResult.success(EnumMap.titleEnumMap);
    }

    @ApiOperation(value = "获取学院对应教研室枚举")
    @GetMapping("/researchByCollegeId")
    public ResponseResult getResearchByCollegeId(@RequestParam(value = "collegeId") CollegeEnum collegeId) {
        List<Research> researches = parameterFactory.collegeEnumCollegeParamMap.get(collegeId).researches;
        return ResponseResult.success(researches);
    }

}
